const actions = {
  addCart(context,payload){
    return new Promise((resolve, reject) => {
      let oldProduct=context.state.cartList.find(item=>item.iid===payload.iid)
      if(oldProduct){
        context.commit('addCounter',oldProduct)
        resolve('添加商品+1')
      }else {
        context.commit('addToCart',payload)
        resolve('成功添加新商品')
      }
    })
  }
}

export default actions

